package com.yuandian.customer.perception.util;

import com.yuandian.bpm.admin.api.feign.RemoteParamService;
import com.yuandian.constant.ConfigKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 远程查询工具类
 */
@Component
@Slf4j
public class RemoteQueryUtil {

	@Autowired
	private RemoteParamService remoteParamService;

	/**
	 * 查询基础服务数据
	 * @param configkey	key值
	 * @return	参数值
	 */
	public String queryBasicServiceDate(String configkey) throws Exception {
		// 获取参数
		String value;
		try {
			long sTime = System.currentTimeMillis();
			value = remoteParamService.getByKeyNoInner(configkey).getData();
			log.info("实时指标-数据上报-远程调用-基础服务-获取公共参数配置-耗时: {} MS", System.currentTimeMillis() - sTime);
		} catch (Exception e) {
			log.error("实时指标-数据上报-远程调用-基础服务-获取公共参数配置-报错: {}", e.getMessage());
			throw new Exception(e);
		}

		return value;
	}


}
